package com.wc.alorithm_blue_bridge._DFS._01游戏;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2025/6/3 14:38
 * @description
 * https://www.lanqiao.cn/problems/17100/learning/?problem_list_id=33&page=1
 */
public class Main {
    /**
     * 思路：
     * dfs + 剪枝即可
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 15, M = 1 << 10;
    static int[] res = new int[N];
    static char[][] ss = new char[N][];
    static int[] state = new int[M];
    static boolean[] use = new boolean[M];
    static int n, cnt = 0;

    public static void main(String[] args) {
        n = sc.nextInt();
        for (int i = 0; i < 1 << n; i++) {
            if (check(i)) state[cnt++] = i;
        }
        for (int i = 1; i <= n; i++) {
            ss[i] = sc.next().toCharArray();
        }

        for (int i = 0; i < cnt; i++) {
            int st = state[i];
            if (!work(ss[1], st)) continue;
            res[1] = st;
            int[] zero = new int[N], one = new int[N];
            for (int j = 0; j < n; j++) {
                int x = st >> j & 1;
                if (x == 0) zero[j] += 1;
                else one[j] += 1;
            }
            use[i] = true;
            if (dfs(2, zero, one)) break;
            use[i] = false;
        }

        for (int i = 1; i <= n; i++) {
            for (int j = 0; j < n; j++) out.print(res[i] >> j & 1);
            out.println();
        }
        out.flush();
    }

    static boolean work(char[] s, int st) {
        for (int i = 0; i < n; i++) {
            if (s[i] != '_' && (st >> i & 1) != (s[i] - '0')) return false;
        }

        return true;
    }

    // pz = preZero, po = preOne
    static boolean dfs (int u, int[] pz, int[] po) {
        if (u == n + 1) return check();

        int pst = res[u - 1];

        for (int i = 0; i < cnt; i++) {
            int st = state[i];
            if (use[i] || !work(ss[u], st)) continue;

            int[] zero = new int[N], one = new int[N];

            boolean success = true;
            for (int j = 0; j < n; j++) {
                int x = st >> j & 1, y = pst >> j & 1;

                if (x == y) {
                    if (x == 0) zero[j] = pz[j] + 1;
                    else one[j] = po[j] + 1;
                } else {
                    if (x == 0) zero[j] = 1;
                    else one[j] = 1;
                }
                if (zero[j] > 2 || one[j] > 2) {
                    success = false;
                    break;
                }
            }
            if (!success) continue;

            res[u] = st;
            use[i] = true;
            if (dfs(u + 1, zero, one)) return true;
            use[i] = false;
        }

        return false;
    }


    // 判断 x 是否满足行要求
    static boolean check(int x) {
        int pre = -1, one = 0;
        int[] cnt = new int[2];
        for (int i = 0; i < n; i++) {
            int cur = x >> i & 1;
            if (cur != pre) {
                cnt[cur] = 1;
                cnt[cur ^ 1] = 0;
            } else cnt[cur] += 1;

            one += cur;
            if (cnt[0] > 2 || cnt[1] > 2) return false;
            pre = cur;
        }
        return one == n / 2;
    }

    static boolean check() {
        int[] num = new int[N];
        for (int i = 1; i <= n; i++) {
            for (int j = 0; j < n; j++) {
                num[j] += res[i] >> j & 1;
            }
        }

        for (int i = 0; i < n; i++) {
            if (num[i] != n / 2) return false;
        }
        return true;
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}

